<template>
  <view
    class="UserDiscussion animate__animated animate__bounceInUp"
    @click="skipToDiscussionDetail"
  >
    <view class="top">
      <view class="title">{{ discussionDetail.title }}</view>
      <view class="time"
        >发布时间：{{
          $formatTime.formatTimeToHHMM(discussionDetail.createTime)
        }}</view
      >
      <view class="content">{{ discussionDetail.content }}</view>
    </view>
    <view class="bottom">
      <view class="categary">{{ discussionDetail.categary }}</view>
      <view class="info">
        <view class="iconBox">
          <image
            src="../../../static/icons/comment.png"
            class="icon"
          ></image>
          <text>{{ discussionDetail.commentCount }}</text>
        </view>
        <view class="iconBox">
          <image src="../../../static/icons/like.png" class="icon"></image>
          <text>{{ discussionDetail.liked }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: "UserDiscussion",
  props:{
    discussionDetail:{
      type: Object,
      required: true
    }
  },
  data(){
    return {
      
    }
  },
  methods:{
    skipToDiscussionDetail() {
      this.$store.commit("m_discussion/clearCurrentDiscussion");
      uni.navigateTo({
        url: `/pages/Discussion/Discussion?id=${this.discussionDetail._id}`,
      });
    },
  }
}
</script>

<style lang="scss" scoped>
.UserDiscussion {
  padding: 20rpx;
  padding-bottom: 10rpx;
  margin-bottom: 40rpx;
  width: 100%;
  height: 250rpx;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #aaa;
  border-radius: 10rpx;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  background-color: #fff;
  .top {
    display: flex;
    flex-direction: column;
    .title {
      font-size: 36rpx;
      font-weight: 500;
      color: #000;
    }
    .time {
      margin-top: 10rpx;
      font-size: 26rpx;
    }
    .content {
      width: 100%;
      margin-top: 10rpx;
      font-size: 30rpx;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  .bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 28rpx;
    .info {
      display: flex;
      align-items: center;

      .iconBox {
        display: flex;
        align-items: center;
        margin-right: 20rpx;
        .icon {
          width: 30rpx;
          height: 30rpx;
          margin-right: 10rpx;
        }
      }
    }
  }
}
</style>